package org.example.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.domain.LastArticle;

import java.util.Date;

@Mapper
public interface LastArticleMapper {

    @Insert("INSERT INTO lastArticle (articleLink,title,pictureLink,date) VALUES (#{articleLink},#{title}," +
            "#{pictureLink},#{date});")
    void addLastArticle(@Param("articleLink") String articleLink, @Param("title") String title,
                        @Param("pictureLink") String pictureLink, @Param("date") Date date);//新增一篇往期推文

    @Select("SELECT * FROM lastArticle ORDER BY date DESC LIMIT #{start},#{number};")
    LastArticle[] getLastArticleLimit(Integer start, Integer number);

}